﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace COFE.Web
{
    public abstract class SupportLink : ILinkContainer
    {

        public abstract IEnumerable<Link> GetLinks();

        public void WriteLinks(XElement parentElement, bool indentLinks = false)
        {
            if (this is ILinkContainer)
            {
                var links = (this as ILinkContainer).GetLinks();
                if (links.Count() > 0)
                {
                    var linkRoot = parentElement;
                    if (indentLinks)
                    {
                        linkRoot = new XElement(XNames.Links);
                        parentElement.Add(linkRoot);
                    }

                    foreach (var link in links)
                        linkRoot.Add(link.ToXml());
                }
            }
        }


    }
}
